﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Web.UI.HtmlControls;

namespace cnFederal.FaCode
{
    public partial class CnfiFunctions
    {

        public static System.Drawing.Color GetRowColor(int index)
        {
            int rest = index % 2;
            System.Drawing.Color color = System.Drawing.Color.White;// "#cbe2f2";
            if (rest == 0)
                color = System.Drawing.Color.FromName("#ccdce4");
            return color;
        }

         public static void AddStyleToControl(Control ctrl ,List<string[]> styleKeyAndValues)
        {

            foreach (string[] s in styleKeyAndValues)
            {
                AddStyleToControl(ctrl, s[0], s[1]);
            }
        }

        public static void AddStyleToControl(Control ctrl, string styleKey, string styleValue)
        {

            if (ctrl is TextBox)
            {
                TextBox txt = (TextBox)ctrl;
                txt.Style.Add(styleKey, styleValue);
            }
            else
                if (ctrl is Label)
                {
                    Label lbl = (Label)ctrl;
                    lbl.Style.Add(styleKey, styleValue);
                }
                else
                    if (ctrl is CheckBox)
                    {
                        CheckBox chk = (CheckBox)ctrl;
                        chk.Style.Add(styleKey, styleValue);
                    }
                    else
                        if (ctrl is Button)
                        {
                            Button btn = (Button)ctrl;
                            btn.Style.Add(styleKey, styleValue);
                        }
                        else
                            if (ctrl is Table)
                            {
                                Table tb = (Table)ctrl;
                                tb.Style.Add(styleKey, styleValue);
                            }
                            else
                                if (ctrl is LinkButton)
                                {
                                    LinkButton lkb = (LinkButton)ctrl;
                                    lkb.Style.Add(styleKey, styleValue);
                                }
                                else
                                    if (ctrl is ImageButton)
                                    {
                                        ImageButton imb = (ImageButton)ctrl;
                                        imb.Style.Add(styleKey, styleValue);
                                    }
                                    else
                                        if (ctrl is HtmlTable)
                                        {
                                            HtmlTable tbl = (HtmlTable)ctrl;
                                            tbl.Style.Add(styleKey, styleValue);
                                        }
                                    else
                                        if (ctrl is HtmlTableCell)
                                        {
                                            HtmlTableCell cel = (HtmlTableCell)ctrl;
                                            cel.Style.Add(styleKey, styleValue);
                                        }
                                   

        }


   
    }
}